/*
 * Copyright 2018-present KunMinX
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.henghai.zhenxuan.data.repository;

import android.util.Log;

import androidx.lifecycle.LifecycleOwner;

import com.henghai.zhenxuan.data.api.AddConsigneeInfoApi;
import com.henghai.zhenxuan.data.api.AdoptListApi;
import com.henghai.zhenxuan.data.api.AdoptPetApi;
import com.henghai.zhenxuan.data.api.AdoptionOrderApi;
import com.henghai.zhenxuan.data.api.AppListApi;
import com.henghai.zhenxuan.data.api.AppTypeApi;
import com.henghai.zhenxuan.data.api.ConsigneeInfoApi;
import com.henghai.zhenxuan.data.api.ConsigneeInfoListApi;
import com.henghai.zhenxuan.data.api.ConversionProductApi;
import com.henghai.zhenxuan.data.api.DeleteConsigneeInfoApi;
import com.henghai.zhenxuan.data.api.GainPointsApi;
import com.henghai.zhenxuan.data.api.GetPrizeCountApi;
import com.henghai.zhenxuan.data.api.GetYingShiToken;
import com.henghai.zhenxuan.data.api.IssueTaskApi;
import com.henghai.zhenxuan.data.api.IssueTaskDetailApi;
import com.henghai.zhenxuan.data.api.LoginApi;
import com.henghai.zhenxuan.data.api.MyTeamAPi;
import com.henghai.zhenxuan.data.api.PrizeDrawProductApi;
import com.henghai.zhenxuan.data.api.PrizeDrawRuleAPi;
import com.henghai.zhenxuan.data.api.PrizeDrawRuleListAPi;
import com.henghai.zhenxuan.data.api.PrizeResAPi;
import com.henghai.zhenxuan.data.api.ProductDetailApi;
import com.henghai.zhenxuan.data.api.ProductOrderInfoApi;
import com.henghai.zhenxuan.data.api.ProductOrdersListApi;
import com.henghai.zhenxuan.data.api.PurchaseProductApi;
import com.henghai.zhenxuan.data.api.QueryNoticeApi;
import com.henghai.zhenxuan.data.api.QuerySignCountAPi;
import com.henghai.zhenxuan.data.api.RaiseFeedCheckApi;
import com.henghai.zhenxuan.data.api.RaiseGetFeedApi;
import com.henghai.zhenxuan.data.api.RaiseListApi;
import com.henghai.zhenxuan.data.api.RaiseSetFeedApi;
import com.henghai.zhenxuan.data.api.RankingListAPi;
import com.henghai.zhenxuan.data.api.ReceiveTaskApi;
import com.henghai.zhenxuan.data.api.RegisterApi;
import com.henghai.zhenxuan.data.api.ResetPwdApi;
import com.henghai.zhenxuan.data.api.SendSmsCodeApi;
import com.henghai.zhenxuan.data.api.SubmitTaskApi;
import com.henghai.zhenxuan.data.api.SysUserPrizesApi;
import com.henghai.zhenxuan.data.api.UnsubscribeApi;
import com.henghai.zhenxuan.data.api.UpdateConsigneeInfoApi;
import com.henghai.zhenxuan.data.api.UpdatePwdAPi;
import com.henghai.zhenxuan.data.api.UpdateUserApi;
import com.henghai.zhenxuan.data.api.UploadAvatarApi;
import com.henghai.zhenxuan.data.api.UploadFileApi;
import com.henghai.zhenxuan.data.api.UserInfoApi;
import com.henghai.zhenxuan.data.api.UserPointsLogListApi;
import com.henghai.zhenxuan.data.api.UserSignInApi;
import com.henghai.zhenxuan.data.api.UserSignInListApi;
import com.henghai.zhenxuan.data.api.WinningApi;
import com.henghai.zhenxuan.data.bean.AddressBean;
import com.henghai.zhenxuan.data.bean.AdoptListBean;
import com.henghai.zhenxuan.data.bean.AdoptionOrderBean;
import com.henghai.zhenxuan.data.bean.AppListTypeBean;
import com.henghai.zhenxuan.data.bean.CheckFeedNumBean;
import com.henghai.zhenxuan.data.bean.ConsigneeInfoBean;
import com.henghai.zhenxuan.data.bean.GetPrizeDrawBean;
import com.henghai.zhenxuan.data.bean.HttpBean;
import com.henghai.zhenxuan.data.bean.IssueTaskBean;
import com.henghai.zhenxuan.data.bean.IssueTaskDetailBean;
import com.henghai.zhenxuan.data.bean.LoginBean;
import com.henghai.zhenxuan.data.bean.LotteryBean;
import com.henghai.zhenxuan.data.bean.MyTeamBean;
import com.henghai.zhenxuan.data.bean.NoticeBean;
import com.henghai.zhenxuan.data.bean.OrderInfoBean;
import com.henghai.zhenxuan.data.bean.PrizeDrawRuleBean;
import com.henghai.zhenxuan.data.bean.PrizeResBean;
import com.henghai.zhenxuan.data.bean.ProductBean;
import com.henghai.zhenxuan.data.bean.ProductInfoBean;

import com.henghai.zhenxuan.data.bean.ProductOrderListBean;
import com.henghai.zhenxuan.data.bean.RaiseBean;
import com.henghai.zhenxuan.data.bean.RankingListBean;
import com.henghai.zhenxuan.data.bean.SysUserPrizesBean;
import com.henghai.zhenxuan.data.bean.UploadFileBean;
import com.henghai.zhenxuan.data.bean.UserInfoBean;
import com.henghai.zhenxuan.data.bean.UserPointsLogBean;
import com.henghai.zhenxuan.data.bean.UserSignListBean;
import com.henghai.zhenxuan.data.bean.WinnerBean;
import com.henghai.zhenxuan.utils.MainHandler;
import com.hjq.http.EasyHttp;
import com.hjq.http.listener.OnHttpListener;
import com.hjq.http.listener.OnUpdateListener;
import com.kongzue.dialogx.dialogs.WaitDialog;
import com.kunminx.architecture.data.response.DataResult;
import com.kunminx.architecture.data.response.ResponseStatus;
import com.kunminx.architecture.data.response.ResultSource;

import java.util.ArrayList;

import okhttp3.Call;


public class DataRepository {

    private static final DataRepository S_REQUEST_MANAGER = new DataRepository();

    private static final String TAG = "DataRepository";

    private DataRepository() {
    }

    public static DataRepository getInstance() {
        return S_REQUEST_MANAGER;
    }

    public void login(LifecycleOwner user, LoginApi api, DataResult.Result<HttpBean<LoginBean>> result) {
        Log.d(TAG, "login: " + user.toString());
        EasyHttp.post(user).tag(api.getApi()).api(api).request(new OnHttpListener<HttpBean<LoginBean>>() {
            @Override
            public void onHttpSuccess(HttpBean<LoginBean> response) {
                if (response == null) {
                    ResponseStatus responseStatus = new ResponseStatus("未知错误", false, ResultSource.NETWORK);
                    result.onResult(new DataResult<>(null, responseStatus));
                    return;
                }
                Log.d(TAG, "onHttpSuccess: " + response.toString());
                ResponseStatus responseStatus = new ResponseStatus(response.getMsg(), response.isRequestSuccess(), ResultSource.NETWORK);
                result.onResult(new DataResult<>(response, responseStatus));
            }

            @Override
            public void onHttpFail(Exception e) {
                Log.d(TAG, "onHttpFail: " + e.getMessage());
                ResponseStatus responseStatus = new ResponseStatus(e.getMessage(), false, ResultSource.NETWORK);
                result.onResult(new DataResult<>(null, responseStatus));
            }
        });
    }

    public void userInfo(LifecycleOwner lifecycleOwner, UserInfoApi api, DataResult.Result<HttpBean<UserInfoBean>> result) {
        EasyHttp.post(lifecycleOwner)
                .api(api)
                .tag(api.getApi())
                .request(new OnHttpListener<HttpBean<UserInfoBean>>() {
                    @Override
                    public void onHttpSuccess(HttpBean<UserInfoBean> response) {
                        if (response == null) {
                            ResponseStatus responseStatus = new ResponseStatus("未知错误", false, ResultSource.NETWORK);
                            result.onResult(new DataResult<>(null, responseStatus));
                            return;
                        }
                        ResponseStatus responseStatus = new ResponseStatus(response.getMsg(), response.isRequestSuccess(), ResultSource.NETWORK);
                        result.onResult(new DataResult<>(response, responseStatus));
                    }

                    @Override
                    public void onHttpFail(Exception e) {
                        Log.d(TAG, "onHttpFail: " + e.getMessage());
                        ResponseStatus responseStatus = new ResponseStatus(e.getMessage(), false, ResultSource.NETWORK);
                        result.onResult(new DataResult<>(null, responseStatus));
                    }
                });

    }

    public void queryNotice(LifecycleOwner lifecycleOwner, QueryNoticeApi api, DataResult.Result<HttpBean<ArrayList<NoticeBean>>> result) {
        EasyHttp.get(lifecycleOwner).tag(api.getApi()).api(api).request(new OnHttpListener<HttpBean<ArrayList<NoticeBean>>>() {
            @Override
            public void onHttpSuccess(HttpBean<ArrayList<NoticeBean>> response) {
                if (response == null) {
                    ResponseStatus responseStatus = new ResponseStatus("未知错误", false, ResultSource.NETWORK);
                    result.onResult(new DataResult<>(null, responseStatus));
                    return;
                }
                ResponseStatus responseStatus = new ResponseStatus(response.getMsg(), response.isRequestSuccess(), ResultSource.NETWORK);
                result.onResult(new DataResult<>(response, responseStatus));
            }

            @Override
            public void onHttpFail(Exception e) {
                ResponseStatus responseStatus = new ResponseStatus(e.getMessage(), false, ResultSource.NETWORK);
                result.onResult(new DataResult<>(null, responseStatus));
            }
        });
    }

    public void getYingShiToken(LifecycleOwner lifecycleOwner, GetYingShiToken api, DataResult.Result<HttpBean> result) {
        EasyHttp.get(lifecycleOwner).api(api.getApi()).request(new OnHttpListener<HttpBean>() {
            @Override
            public void onHttpSuccess(HttpBean response) {
                Log.d(TAG, "onHttpSuccess: " + response.toString());
                if (response == null) {
                    ResponseStatus responseStatus = new ResponseStatus("未知错误", false, ResultSource.NETWORK);
                    result.onResult(new DataResult<>(null, responseStatus));
                    return;
                }
                ResponseStatus responseStatus = new ResponseStatus(response.getMsg(), response.isRequestSuccess(), ResultSource.NETWORK);
                result.onResult(new DataResult<>(response, responseStatus));
            }

            @Override
            public void onHttpFail(Exception e) {
                ResponseStatus responseStatus = new ResponseStatus(e.getMessage(), false, ResultSource.NETWORK);
                result.onResult(new DataResult<>(null, responseStatus));
            }
        });
    }

    /**
     * 领养中心
     *
     * @param lifecycleOwner
     * @param api
     * @param result
     */
    public void adoptList(LifecycleOwner lifecycleOwner, AdoptListApi api, DataResult.Result<HttpBean<AdoptListBean>> result) {
        EasyHttp.get(lifecycleOwner).tag(api.getApi()).api(api).request(new OnHttpListener<HttpBean<AdoptListBean>>() {
            @Override
            public void onHttpStart(Call call) {
                WaitDialog.show("加载中...");
                OnHttpListener.super.onHttpStart(call);
            }

            @Override
            public void onHttpEnd(Call call) {
                WaitDialog.dismiss();
                OnHttpListener.super.onHttpEnd(call);
            }
            @Override
            public void onHttpSuccess(HttpBean<AdoptListBean> response) {
                if (response == null) {
                    ResponseStatus responseStatus = new ResponseStatus("未知错误", false, ResultSource.NETWORK);
                    result.onResult(new DataResult<>(null, responseStatus));
                    return;
                }
                ResponseStatus responseStatus = new ResponseStatus(response.getMsg(), response.isRequestSuccess(), ResultSource.NETWORK);
                result.onResult(new DataResult<>(response, responseStatus));
            }

            @Override
            public void onHttpFail(Exception e) {
                ResponseStatus responseStatus = new ResponseStatus(e.getMessage(), false, ResultSource.NETWORK);
                result.onResult(new DataResult<>(null, responseStatus));
            }
        });
    }

    /**
     * 领养宠物
     *
     * @param lifecycleOwner
     * @param api
     * @param result
     */
    public void adoptResult(LifecycleOwner lifecycleOwner, AdoptPetApi api, DataResult.Result<HttpBean<HttpBean>> result) {
        EasyHttp.post(lifecycleOwner).tag(api.getApi()).api(api).request(new OnHttpListener<HttpBean<HttpBean>>() {
            @Override
            public void onHttpSuccess(HttpBean response) {
                Log.d(TAG, "onHttpSuccess: " + response);
                if (response == null) {
                    ResponseStatus responseStatus = new ResponseStatus("未知错误", false, ResultSource.NETWORK);
                    result.onResult(new DataResult<>(null, responseStatus));
                    return;
                }
                ResponseStatus responseStatus = new ResponseStatus(response.getMsg(), response.isRequestSuccess(), ResultSource.NETWORK);
                result.onResult(new DataResult<>(response, responseStatus));
            }

            @Override
            public void onHttpFail(Exception e) {
                ResponseStatus responseStatus = new ResponseStatus(e.getMessage(), false, ResultSource.NETWORK);
                result.onResult(new DataResult<>(null, responseStatus));
            }
        });
    }

    public void adoptionOrderResult(LifecycleOwner lifecycleOwner, AdoptionOrderApi api, DataResult.Result<HttpBean<AdoptionOrderBean>> result) {
        EasyHttp.post(lifecycleOwner).tag(api.getApi()).api(api).request(new OnHttpListener<HttpBean<AdoptionOrderBean>>() {
            @Override
            public void onHttpStart(Call call) {
                WaitDialog.show("加载中...");
                OnHttpListener.super.onHttpStart(call);
            }

            @Override
            public void onHttpEnd(Call call) {
                WaitDialog.dismiss();
                OnHttpListener.super.onHttpEnd(call);
            }
            @Override
            public void onHttpSuccess(HttpBean response) {
                Log.d(TAG, "onHttpSuccess: " + response);
                if (response == null) {
                    ResponseStatus responseStatus = new ResponseStatus("未知错误", false, ResultSource.NETWORK);
                    result.onResult(new DataResult<>(null, responseStatus));
                    return;
                }
                ResponseStatus responseStatus = new ResponseStatus(response.getMsg(), response.isRequestSuccess(), ResultSource.NETWORK);
                result.onResult(new DataResult<>(response, responseStatus));
            }

            @Override
            public void onHttpFail(Exception e) {
                ResponseStatus responseStatus = new ResponseStatus(e.getMessage(), false, ResultSource.NETWORK);
                result.onResult(new DataResult<>(null, responseStatus));
            }
        });
    }

    /**
     * 饲养园
     *
     * @param lifecycleOwner
     * @param api
     * @param result
     */
    public void raisrList(LifecycleOwner lifecycleOwner, RaiseListApi api, DataResult.Result<HttpBean<RaiseBean>> result) {
        EasyHttp.get(lifecycleOwner).tag(api.getApi()).api(api).request(new OnHttpListener<HttpBean<RaiseBean>>() {
            @Override
            public void onHttpStart(Call call) {
                WaitDialog.show("加载中...");
                OnHttpListener.super.onHttpStart(call);
            }

            @Override
            public void onHttpEnd(Call call) {
                WaitDialog.dismiss();
                OnHttpListener.super.onHttpEnd(call);
            }

            @Override
            public void onHttpSuccess(HttpBean<RaiseBean> response) {
                if (response == null) {
                    ResponseStatus responseStatus = new ResponseStatus("未知错误", false, ResultSource.NETWORK);
                    result.onResult(new DataResult<>(null, responseStatus));
                    return;
                }
                ResponseStatus responseStatus = new ResponseStatus(response.getMsg(), response.isRequestSuccess(), ResultSource.NETWORK);
                result.onResult(new DataResult<>(response, responseStatus));
            }

            @Override
            public void onHttpFail(Exception e) {
                ResponseStatus responseStatus = new ResponseStatus(e.getMessage(), false, ResultSource.NETWORK);
                result.onResult(new DataResult<>(null, responseStatus));
            }
        });
    }

    /**
     * 检查是否可以获取饲料
     *
     * @param lifecycleOwner
     */
    public void canAcquire(LifecycleOwner lifecycleOwner, RaiseFeedCheckApi api, DataResult.Result<HttpBean<CheckFeedNumBean>> result) {
        EasyHttp.get(lifecycleOwner).api(api.getApi()).request(new OnHttpListener<HttpBean<CheckFeedNumBean>>() {
            @Override
            public void onHttpStart(Call call) {
                WaitDialog.show("加载中...");
                OnHttpListener.super.onHttpStart(call);
            }

            @Override
            public void onHttpEnd(Call call) {
                WaitDialog.dismiss();
                OnHttpListener.super.onHttpEnd(call);
            }
            @Override
            public void onHttpSuccess(HttpBean<CheckFeedNumBean> response) {
                Log.d(TAG, "onHttpSuccess: " + response);
                if (response == null) {
                    ResponseStatus responseStatus = new ResponseStatus("未知错误", false, ResultSource.NETWORK);
                    result.onResult(new DataResult<>(null, responseStatus));
                    return;
                }
                ResponseStatus responseStatus = new ResponseStatus(response.getMsg(), response.isRequestSuccess(), ResultSource.NETWORK);
                result.onResult(new DataResult<>(response, responseStatus));
            }

            @Override
            public void onHttpFail(Exception e) {
                ResponseStatus responseStatus = new ResponseStatus(e.getMessage(), false, ResultSource.NETWORK);
                result.onResult(new DataResult<>(null, responseStatus));
            }
        });
    }

    /**
     * 获取饲料
     *
     * @param lifecycleOwner
     */
    public void getFeed(LifecycleOwner lifecycleOwner, RaiseGetFeedApi api, DataResult.Result<HttpBean> result) {
        EasyHttp.post(lifecycleOwner).api(api).request(new OnHttpListener<HttpBean>() {
            @Override
            public void onHttpStart(Call call) {
                WaitDialog.show("加载中...");
                OnHttpListener.super.onHttpStart(call);
            }

            @Override
            public void onHttpEnd(Call call) {
                WaitDialog.dismiss();
                OnHttpListener.super.onHttpEnd(call);
            }
            @Override
            public void onHttpSuccess(HttpBean response) {
                Log.d(TAG, "onHttpSuccess: " + response);
                if (response == null) {
                    ResponseStatus responseStatus = new ResponseStatus("未知错误", false, ResultSource.NETWORK);
                    result.onResult(new DataResult<>(null, responseStatus));
                    return;
                }
                ResponseStatus responseStatus = new ResponseStatus(response.getMsg(), response.isRequestSuccess(), ResultSource.NETWORK);
                result.onResult(new DataResult<>(response, responseStatus));
            }

            @Override
            public void onHttpFail(Exception e) {
                ResponseStatus responseStatus = new ResponseStatus(e.getMessage(), false, ResultSource.NETWORK);
                result.onResult(new DataResult<>(null, responseStatus));
            }
        });
    }

    /**
     * 获取饲料数量
     *
     * @param lifecycleOwner
     */
    public void getFeedConut(LifecycleOwner lifecycleOwner, RaiseFeedCheckApi api, DataResult.Result<HttpBean> result) {
        EasyHttp.get(lifecycleOwner).api(api.getFeedCount()).request(new OnHttpListener<HttpBean>() {
            @Override
            public void onHttpStart(Call call) {
                WaitDialog.show("加载中...");
                OnHttpListener.super.onHttpStart(call);
            }

            @Override
            public void onHttpEnd(Call call) {
                WaitDialog.dismiss();
                OnHttpListener.super.onHttpEnd(call);
            }
            @Override
            public void onHttpSuccess(HttpBean response) {
                Log.d(TAG, "onHttpSuccess: " + response);
                if (response == null) {
                    ResponseStatus responseStatus = new ResponseStatus("未知错误", false, ResultSource.NETWORK);
                    result.onResult(new DataResult<>(null, responseStatus));
                    return;
                }
                ResponseStatus responseStatus = new ResponseStatus(response.getMsg(), response.isRequestSuccess(), ResultSource.NETWORK);
                result.onResult(new DataResult<>(response, responseStatus));
            }

            @Override
            public void onHttpFail(Exception e) {
                ResponseStatus responseStatus = new ResponseStatus(e.getMessage(), false, ResultSource.NETWORK);
                result.onResult(new DataResult<>(null, responseStatus));
            }
        });
    }

    /**
     * 投喂饲料
     *
     * @param lifecycleOwner
     */
    public void setFeed(LifecycleOwner lifecycleOwner, RaiseSetFeedApi api, DataResult.Result<HttpBean> result) {
        EasyHttp.post(lifecycleOwner).api(api).request(new OnHttpListener<HttpBean>() {
            @Override
            public void onHttpStart(Call call) {
                WaitDialog.show("加载中...");
                OnHttpListener.super.onHttpStart(call);
            }

            @Override
            public void onHttpEnd(Call call) {
                WaitDialog.dismiss();
                OnHttpListener.super.onHttpEnd(call);
            }
            @Override
            public void onHttpSuccess(HttpBean response) {
                Log.d(TAG, "onHttpSuccess: " + response);
                if (response == null) {
                    ResponseStatus responseStatus = new ResponseStatus("未知错误", false, ResultSource.NETWORK);
                    result.onResult(new DataResult<>(null, responseStatus));
                    return;
                }
                ResponseStatus responseStatus = new ResponseStatus(response.getMsg(), response.isRequestSuccess(), ResultSource.NETWORK);
                result.onResult(new DataResult<>(response, responseStatus));
            }

            @Override
            public void onHttpFail(Exception e) {
                ResponseStatus responseStatus = new ResponseStatus(e.getMessage(), false, ResultSource.NETWORK);
                result.onResult(new DataResult<>(null, responseStatus));
            }
        });
    }


    public void issueTask(LifecycleOwner lifecycleOwner, IssueTaskApi api, DataResult.Result<HttpBean<IssueTaskBean>> result) {

        EasyHttp.get(lifecycleOwner).tag(api.getApi()).api(api).request(new OnHttpListener<HttpBean<IssueTaskBean>>() {
            @Override
            public void onHttpSuccess(HttpBean<IssueTaskBean> response) {
                if (response == null) {
                    ResponseStatus responseStatus = new ResponseStatus("未知错误", false, ResultSource.NETWORK);
                    result.onResult(new DataResult<>(null, responseStatus));
                    return;
                }
                ResponseStatus responseStatus = new ResponseStatus(response.getMsg(), response.isRequestSuccess(), ResultSource.NETWORK);
                result.onResult(new DataResult<>(response, responseStatus));
            }

            @Override
            public void onHttpFail(Exception e) {
                ResponseStatus responseStatus = new ResponseStatus(e.getMessage(), false, ResultSource.NETWORK);
                result.onResult(new DataResult<>(null, responseStatus));
            }
        });
    }

    public void issueTaskDetail(LifecycleOwner lifecycleOwner, IssueTaskDetailApi api, DataResult.Result<HttpBean<IssueTaskDetailBean>> result) {

        EasyHttp.get(lifecycleOwner).tag(api.getApi()).api(api).request(new OnHttpListener<HttpBean<IssueTaskDetailBean>>() {
            @Override
            public void onHttpSuccess(HttpBean<IssueTaskDetailBean> response) {
                if (response == null) {
                    ResponseStatus responseStatus = new ResponseStatus("未知错误", false, ResultSource.NETWORK);
                    result.onResult(new DataResult<>(null, responseStatus));
                    return;
                }
                ResponseStatus responseStatus = new ResponseStatus(response.getMsg(), response.isRequestSuccess(), ResultSource.NETWORK);
                result.onResult(new DataResult<>(response, responseStatus));
            }

            @Override
            public void onHttpFail(Exception e) {
                ResponseStatus responseStatus = new ResponseStatus(e.getMessage(), false, ResultSource.NETWORK);
                result.onResult(new DataResult<>(null, responseStatus));
            }
        });
    }

    public void appList(LifecycleOwner lifecycleOwner, AppListApi api, DataResult.Result<HttpBean<ProductBean>> result) {
        EasyHttp.post(lifecycleOwner).tag(api.getApi()).api(api).request(new OnHttpListener<HttpBean<ProductBean>>() {
            @Override
            public void onHttpSuccess(HttpBean<ProductBean> response) {
                if (response == null) {
                    ResponseStatus responseStatus = new ResponseStatus("未知错误", false, ResultSource.NETWORK);
                    result.onResult(new DataResult<>(null, responseStatus));
                    return;
                }
                ResponseStatus responseStatus = new ResponseStatus(response.getMsg(), response.isRequestSuccess(), ResultSource.NETWORK);
                result.onResult(new DataResult<>(response, responseStatus));
            }

            @Override
            public void onHttpFail(Exception e) {
                ResponseStatus responseStatus = new ResponseStatus(e.getMessage(), false, ResultSource.NETWORK);
                result.onResult(new DataResult<>(null, responseStatus));
            }
        });
    }

    public void appType(LifecycleOwner lifecycleOwner, AppTypeApi api, DataResult.Result<HttpBean<AppListTypeBean>> result) {

        EasyHttp.get(lifecycleOwner).tag(api.getApi()).api(api).request(new OnHttpListener<HttpBean<AppListTypeBean>>() {
            @Override
            public void onHttpSuccess(HttpBean<AppListTypeBean> response) {
                if (response == null) {
                    ResponseStatus responseStatus = new ResponseStatus("未知错误", false, ResultSource.NETWORK);
                    result.onResult(new DataResult<>(null, responseStatus));
                    return;
                }
                ResponseStatus responseStatus = new ResponseStatus(response.getMsg(), response.isRequestSuccess(), ResultSource.NETWORK);
                result.onResult(new DataResult<>(response, responseStatus));
            }

            @Override
            public void onHttpFail(Exception e) {
                ResponseStatus responseStatus = new ResponseStatus(e.getMessage(), false, ResultSource.NETWORK);
                result.onResult(new DataResult<>(null, responseStatus));
            }
        });
    }

    public void productInfo(LifecycleOwner lifecycleOwner, ProductDetailApi api, DataResult.Result<HttpBean<ProductInfoBean>> result) {

        EasyHttp.get(lifecycleOwner).tag(api.getApi()).api(api).request(new OnHttpListener<HttpBean<ProductInfoBean>>() {
            @Override
            public void onHttpSuccess(HttpBean<ProductInfoBean> response) {
                if (response == null) {
                    ResponseStatus responseStatus = new ResponseStatus("未知错误", false, ResultSource.NETWORK);
                    result.onResult(new DataResult<>(null, responseStatus));
                    return;
                }
                ResponseStatus responseStatus = new ResponseStatus(response.getMsg(), response.isRequestSuccess(), ResultSource.NETWORK);
                result.onResult(new DataResult<>(response, responseStatus));
            }

            @Override
            public void onHttpFail(Exception e) {
                ResponseStatus responseStatus = new ResponseStatus(e.getMessage(), false, ResultSource.NETWORK);
                result.onResult(new DataResult<>(null, responseStatus));
            }
        });
    }

    public void productOrderInfo(LifecycleOwner lifecycleOwner, ProductOrderInfoApi api, DataResult.Result<HttpBean<OrderInfoBean>> result) {

        EasyHttp.get(lifecycleOwner).tag(api.getApi()).api(api).request(new OnHttpListener<HttpBean<OrderInfoBean>>() {
            @Override
            public void onHttpSuccess(HttpBean<OrderInfoBean> response) {
                if (response == null) {
                    ResponseStatus responseStatus = new ResponseStatus("未知错误", false, ResultSource.NETWORK);
                    result.onResult(new DataResult<>(null, responseStatus));
                    return;
                }
                ResponseStatus responseStatus = new ResponseStatus(response.getMsg(), response.isRequestSuccess(), ResultSource.NETWORK);
                result.onResult(new DataResult<>(response, responseStatus));
            }

            @Override
            public void onHttpFail(Exception e) {
                ResponseStatus responseStatus = new ResponseStatus(e.getMessage(), false, ResultSource.NETWORK);
                result.onResult(new DataResult<>(null, responseStatus));
            }
        });
    }

    public void receiveTask(LifecycleOwner lifecycleOwner, ReceiveTaskApi api, DataResult.Result<HttpBean> result) {

        EasyHttp.post(lifecycleOwner).api(api).request(new OnHttpListener<HttpBean>() {
            @Override
            public void onHttpSuccess(HttpBean response) {
                if (response == null) {
                    ResponseStatus responseStatus = new ResponseStatus("未知错误", false, ResultSource.NETWORK);
                    result.onResult(new DataResult<>(null, responseStatus));
                    return;
                }
                ResponseStatus responseStatus = new ResponseStatus(response.getMsg(), response.isRequestSuccess(), ResultSource.NETWORK);
                result.onResult(new DataResult<>(response, responseStatus));
            }

            @Override
            public void onHttpFail(Exception e) {
                ResponseStatus responseStatus = new ResponseStatus(e.getMessage(), false, ResultSource.NETWORK);
                result.onResult(new DataResult<>(null, responseStatus));
            }
        });
    }

    public void submitTask(LifecycleOwner lifecycleOwner, SubmitTaskApi api, DataResult.Result<HttpBean> result) {

        EasyHttp.post(lifecycleOwner).api(api).request(new OnHttpListener<HttpBean>() {
            @Override
            public void onHttpSuccess(HttpBean response) {
                if (response == null) {
                    ResponseStatus responseStatus = new ResponseStatus("未知错误", false, ResultSource.NETWORK);
                    result.onResult(new DataResult<>(null, responseStatus));
                    return;
                }
                ResponseStatus responseStatus = new ResponseStatus(response.getMsg(), response.isRequestSuccess(), ResultSource.NETWORK);
                result.onResult(new DataResult<>(response, responseStatus));
            }

            @Override
            public void onHttpFail(Exception e) {
                ResponseStatus responseStatus = new ResponseStatus(e.getMessage(), false, ResultSource.NETWORK);
                result.onResult(new DataResult<>(null, responseStatus));
            }
        });
    }

    public void uploadFile(LifecycleOwner lifecycleOwner, UploadFileApi api, DataResult.Result<UploadFileBean> result) {
        EasyHttp.post(lifecycleOwner)
                .tag(api.getApi())
                .api(api).request(new OnUpdateListener<UploadFileBean>() {
                    @Override
                    public void onUpdateProgressChange(int i) {
                        MainHandler.INSTANCE.post(() -> WaitDialog.show("正在提交"));
                    }

                    @Override
                    public void onUpdateSuccess(UploadFileBean response) {
                        if (response == null) {
                            ResponseStatus responseStatus = new ResponseStatus("未知错误", false, ResultSource.NETWORK);
                            result.onResult(new DataResult<>(null, responseStatus));
                            return;
                        }
                        ResponseStatus responseStatus = new ResponseStatus(response.getMsg(), response.isRequestSuccess(), ResultSource.NETWORK);
                        result.onResult(new DataResult<>(response, responseStatus));
                    }

                    @Override
                    public void onUpdateFail(Exception e) {
                        ResponseStatus responseStatus = new ResponseStatus(e.getMessage(), false, ResultSource.NETWORK);
                        result.onResult(new DataResult<>(null, responseStatus));
                    }
                });

    }

    public void uploadAvatarFile(LifecycleOwner lifecycleOwner, UploadAvatarApi api, DataResult.Result<UploadFileBean> result) {
        EasyHttp.post(lifecycleOwner)
                .tag(api.getApi())
                .api(api).request(new OnUpdateListener<UploadFileBean>() {
                    @Override
                    public void onUpdateProgressChange(int i) {
                        MainHandler.INSTANCE.post(() -> WaitDialog.show("正在提交"));
                    }

                    @Override
                    public void onUpdateSuccess(UploadFileBean response) {
                        if (response == null) {
                            ResponseStatus responseStatus = new ResponseStatus("未知错误", false, ResultSource.NETWORK);
                            result.onResult(new DataResult<>(null, responseStatus));
                            return;
                        }
                        ResponseStatus responseStatus = new ResponseStatus(response.getMsg(), response.isRequestSuccess(), ResultSource.NETWORK);
                        result.onResult(new DataResult<>(response, responseStatus));
                    }

                    @Override
                    public void onUpdateFail(Exception e) {
                        ResponseStatus responseStatus = new ResponseStatus(e.getMessage(), false, ResultSource.NETWORK);
                        result.onResult(new DataResult<>(null, responseStatus));
                    }
                });

    }

    public void getConsigneeInfoList(LifecycleOwner lifecycleOwner, ConsigneeInfoListApi api, DataResult.Result<HttpBean<ConsigneeInfoBean>> result) {
        EasyHttp.get(lifecycleOwner)
                .api(api).request(new OnHttpListener<HttpBean<ConsigneeInfoBean>>() {
                    @Override
                    public void onHttpSuccess(HttpBean<ConsigneeInfoBean> response) {
                        if (response == null) {
                            ResponseStatus responseStatus = new ResponseStatus("未知错误", false, ResultSource.NETWORK);
                            result.onResult(new DataResult<>(null, responseStatus));
                            return;
                        }
                        ResponseStatus responseStatus = new ResponseStatus(response.getMsg(), response.isRequestSuccess(), ResultSource.NETWORK);
                        result.onResult(new DataResult<>(response, responseStatus));
                    }

                    @Override
                    public void onHttpFail(Exception e) {
                        ResponseStatus responseStatus = new ResponseStatus(e.getMessage(), false, ResultSource.NETWORK);
                        result.onResult(new DataResult<>(null, responseStatus));
                    }
                });

    }

    public void updateConsigneeInfo(LifecycleOwner lifecycleOwner, UpdateConsigneeInfoApi api, DataResult.Result<HttpBean> result) {

        EasyHttp.post(lifecycleOwner)
                .tag(api.getApi())
                .api(api).request(new OnHttpListener<HttpBean>() {
                    @Override
                    public void onHttpSuccess(HttpBean response) {
                        if (response == null) {
                            ResponseStatus responseStatus = new ResponseStatus("未知错误", false, ResultSource.NETWORK);
                            result.onResult(new DataResult<>(null, responseStatus));
                            return;
                        }
                        ResponseStatus responseStatus = new ResponseStatus(response.getMsg(), response.isRequestSuccess(), ResultSource.NETWORK);
                        result.onResult(new DataResult<>(response, responseStatus));
                    }

                    @Override
                    public void onHttpFail(Exception e) {
                        ResponseStatus responseStatus = new ResponseStatus(e.getMessage(), false, ResultSource.NETWORK);
                        result.onResult(new DataResult<>(null, responseStatus));
                    }
                });

    }

    public void deleteConsigneeInfo(LifecycleOwner lifecycleOwner, DeleteConsigneeInfoApi api, DataResult.Result<HttpBean> result) {
        EasyHttp.post(lifecycleOwner)
                .tag(api.getApi())
                .api(api).request(new OnHttpListener<HttpBean>() {
                    @Override
                    public void onHttpSuccess(HttpBean response) {
                        if (response == null) {
                            ResponseStatus responseStatus = new ResponseStatus("未知错误", false, ResultSource.NETWORK);
                            result.onResult(new DataResult<>(null, responseStatus));
                            return;
                        }
                        ResponseStatus responseStatus = new ResponseStatus(response.getMsg(), response.isRequestSuccess(), ResultSource.NETWORK);
                        result.onResult(new DataResult<>(response, responseStatus));
                    }

                    @Override
                    public void onHttpFail(Exception e) {
                        ResponseStatus responseStatus = new ResponseStatus(e.getMessage(), false, ResultSource.NETWORK);
                        result.onResult(new DataResult<>(null, responseStatus));
                    }
                });

    }

    public void addConsigneeInfo(LifecycleOwner lifecycleOwner, AddConsigneeInfoApi api, DataResult.Result<HttpBean> result) {
        EasyHttp.post(lifecycleOwner)
                .tag(api.getApi())
                .api(api).request(new OnHttpListener<HttpBean>() {
                    @Override
                    public void onHttpSuccess(HttpBean response) {
                        if (response == null) {
                            ResponseStatus responseStatus = new ResponseStatus("未知错误", false, ResultSource.NETWORK);
                            result.onResult(new DataResult<>(null, responseStatus));
                            return;
                        }
                        ResponseStatus responseStatus = new ResponseStatus(response.getMsg(), response.isRequestSuccess(), ResultSource.NETWORK);
                        result.onResult(new DataResult<>(response, responseStatus));
                    }

                    @Override
                    public void onHttpFail(Exception e) {
                        ResponseStatus responseStatus = new ResponseStatus(e.getMessage(), false, ResultSource.NETWORK);
                        result.onResult(new DataResult<>(null, responseStatus));
                    }
                });

    }


    public void conversionProduct(LifecycleOwner lifecycleOwner, ConversionProductApi api, DataResult.Result<HttpBean> result) {
        EasyHttp.post(lifecycleOwner)
                .tag(api.getApi())
                .api(api).request(new OnHttpListener<HttpBean>() {
                    @Override
                    public void onHttpSuccess(HttpBean response) {
                        if (response == null) {
                            ResponseStatus responseStatus = new ResponseStatus("未知错误", false, ResultSource.NETWORK);
                            result.onResult(new DataResult<>(null, responseStatus));
                            return;
                        }
                        ResponseStatus responseStatus = new ResponseStatus(response.getMsg(), response.isRequestSuccess(), ResultSource.NETWORK);
                        result.onResult(new DataResult<>(response, responseStatus));
                    }

                    @Override
                    public void onHttpFail(Exception e) {
                        ResponseStatus responseStatus = new ResponseStatus(e.getMessage(), false, ResultSource.NETWORK);
                        result.onResult(new DataResult<>(null, responseStatus));
                    }
                });

    }

    public void purchaseProduct(LifecycleOwner lifecycleOwner, PurchaseProductApi api, DataResult.Result<HttpBean> result) {
        EasyHttp.post(lifecycleOwner)
                .api(api).request(new OnHttpListener<HttpBean>() {
                    @Override
                    public void onHttpSuccess(HttpBean response) {
                        if (response == null) {
                            ResponseStatus responseStatus = new ResponseStatus("未知错误", false, ResultSource.NETWORK);
                            result.onResult(new DataResult<>(null, responseStatus));
                            return;
                        }
                        ResponseStatus responseStatus = new ResponseStatus(response.getMsg(), response.isRequestSuccess(), ResultSource.NETWORK);
                        result.onResult(new DataResult<>(response, responseStatus));
                    }

                    @Override
                    public void onHttpFail(Exception e) {
                        ResponseStatus responseStatus = new ResponseStatus(e.getMessage(), false, ResultSource.NETWORK);
                        result.onResult(new DataResult<>(null, responseStatus));
                    }
                });

    }


    public void consigneeInfo(LifecycleOwner lifecycleOwner, ConsigneeInfoApi api, DataResult.Result<HttpBean<AddressBean>> result) {
        EasyHttp.get(lifecycleOwner)
                .api(api).request(new OnHttpListener<HttpBean<AddressBean>>() {
                    @Override
                    public void onHttpSuccess(HttpBean<AddressBean> response) {
                        if (response == null) {
                            ResponseStatus responseStatus = new ResponseStatus("未知错误", false, ResultSource.NETWORK);
                            result.onResult(new DataResult<>(null, responseStatus));
                            return;
                        }
                        ResponseStatus responseStatus = new ResponseStatus(response.getMsg(), response.isRequestSuccess(), ResultSource.NETWORK);
                        result.onResult(new DataResult<>(response, responseStatus));
                    }

                    @Override
                    public void onHttpFail(Exception e) {
                        ResponseStatus responseStatus = new ResponseStatus(e.getMessage(), false, ResultSource.NETWORK);
                        result.onResult(new DataResult<>(null, responseStatus));
                    }
                });

    }

    public void productOrdersList(LifecycleOwner lifecycleOwner, ProductOrdersListApi api, DataResult.Result<HttpBean<ProductOrderListBean>> result) {
        EasyHttp.post(lifecycleOwner)
                .api(api).request(new OnHttpListener<HttpBean<ProductOrderListBean>>() {
                    @Override
                    public void onHttpSuccess(HttpBean<ProductOrderListBean> response) {
                        if (response == null) {
                            ResponseStatus responseStatus = new ResponseStatus("未知错误", false, ResultSource.NETWORK);
                            result.onResult(new DataResult<>(null, responseStatus));
                            return;
                        }
                        ResponseStatus responseStatus = new ResponseStatus(response.getMsg(), response.isRequestSuccess(), ResultSource.NETWORK);
                        result.onResult(new DataResult<>(response, responseStatus));
                    }

                    @Override
                    public void onHttpFail(Exception e) {
                        ResponseStatus responseStatus = new ResponseStatus(e.getMessage(), false, ResultSource.NETWORK);
                        result.onResult(new DataResult<>(null, responseStatus));
                    }
                });

    }

    public void gainPoints(LifecycleOwner lifecycleOwner, GainPointsApi api, DataResult.Result<HttpBean> result) {
        EasyHttp.post(lifecycleOwner)
                .api(api).request(new OnHttpListener<HttpBean>() {
                    @Override
                    public void onHttpSuccess(HttpBean response) {
                        if (response == null) {
                            ResponseStatus responseStatus = new ResponseStatus("未知错误", false, ResultSource.NETWORK);
                            result.onResult(new DataResult<>(null, responseStatus));
                            return;
                        }
                        ResponseStatus responseStatus = new ResponseStatus(response.getMsg(), response.isRequestSuccess(), ResultSource.NETWORK);
                        result.onResult(new DataResult<>(response, responseStatus));
                    }

                    @Override
                    public void onHttpFail(Exception e) {
                        ResponseStatus responseStatus = new ResponseStatus(e.getMessage(), false, ResultSource.NETWORK);
                        result.onResult(new DataResult<>(null, responseStatus));
                    }
                });

    }

    public void userPointsLog(LifecycleOwner lifecycleOwner, UserPointsLogListApi api, DataResult.Result<HttpBean<UserPointsLogBean>> result) {
        EasyHttp.post(lifecycleOwner)
                .api(api).request(new OnHttpListener<HttpBean<UserPointsLogBean>>() {
                    @Override
                    public void onHttpSuccess(HttpBean<UserPointsLogBean> response) {
                        if (response == null) {
                            ResponseStatus responseStatus = new ResponseStatus("未知错误", false, ResultSource.NETWORK);
                            result.onResult(new DataResult<>(null, responseStatus));
                            return;
                        }
                        ResponseStatus responseStatus = new ResponseStatus(response.getMsg(), response.isRequestSuccess(), ResultSource.NETWORK);
                        result.onResult(new DataResult<>(response, responseStatus));
                    }

                    @Override
                    public void onHttpFail(Exception e) {
                        ResponseStatus responseStatus = new ResponseStatus(e.getMessage(), false, ResultSource.NETWORK);
                        result.onResult(new DataResult<>(null, responseStatus));
                    }
                });

    }

    public void sysUserPrizes(LifecycleOwner lifecycleOwner, SysUserPrizesApi api, DataResult.Result<HttpBean<SysUserPrizesBean>> result) {
        EasyHttp.get(lifecycleOwner)
                .api(api).request(new OnHttpListener<HttpBean<SysUserPrizesBean>>() {
                    @Override
                    public void onHttpSuccess(HttpBean<SysUserPrizesBean> response) {
                        if (response == null) {
                            ResponseStatus responseStatus = new ResponseStatus("未知错误", false, ResultSource.NETWORK);
                            result.onResult(new DataResult<>(null, responseStatus));
                            return;
                        }
                        ResponseStatus responseStatus = new ResponseStatus(response.getMsg(), response.isRequestSuccess(), ResultSource.NETWORK);
                        result.onResult(new DataResult<>(response, responseStatus));
                    }

                    @Override
                    public void onHttpFail(Exception e) {
                        ResponseStatus responseStatus = new ResponseStatus(e.getMessage(), false, ResultSource.NETWORK);
                        result.onResult(new DataResult<>(null, responseStatus));
                    }
                });

    }

    public void userSign(LifecycleOwner lifecycleOwner, UserSignInApi api, DataResult.Result<HttpBean> result) {
        EasyHttp.get(lifecycleOwner)
                .tag(api.getApi())
                .api(api).request(new OnHttpListener<HttpBean>() {
                    @Override
                    public void onHttpSuccess(HttpBean response) {
                        if (response == null) {
                            ResponseStatus responseStatus = new ResponseStatus("未知错误", false, ResultSource.NETWORK);
                            result.onResult(new DataResult<>(null, responseStatus));
                            return;
                        }
                        ResponseStatus responseStatus = new ResponseStatus(response.getMsg(), response.isRequestSuccess(), ResultSource.NETWORK);
                        result.onResult(new DataResult<>(response, responseStatus));
                    }

                    @Override
                    public void onHttpFail(Exception e) {
                        ResponseStatus responseStatus = new ResponseStatus(e.getMessage(), false, ResultSource.NETWORK);
                        result.onResult(new DataResult<>(null, responseStatus));
                    }
                });

    }

    public void userSignList(LifecycleOwner lifecycleOwner, UserSignInListApi api, DataResult.Result<HttpBean<UserSignListBean>> result) {
        EasyHttp.get(lifecycleOwner)
                .tag(api.getApi())
                .api(api).request(new OnHttpListener<HttpBean<UserSignListBean>>() {
                    @Override
                    public void onHttpSuccess(HttpBean<UserSignListBean> response) {
                        if (response == null) {
                            ResponseStatus responseStatus = new ResponseStatus("未知错误", false, ResultSource.NETWORK);
                            result.onResult(new DataResult<>(null, responseStatus));
                            return;
                        }
                        ResponseStatus responseStatus = new ResponseStatus(response.getMsg(), response.isRequestSuccess(), ResultSource.NETWORK);
                        result.onResult(new DataResult<>(response, responseStatus));
                    }

                    @Override
                    public void onHttpFail(Exception e) {
                        ResponseStatus responseStatus = new ResponseStatus(e.getMessage(), false, ResultSource.NETWORK);
                        result.onResult(new DataResult<>(null, responseStatus));
                    }
                });

    }

    public void prizeDrawProductList(LifecycleOwner lifecycleOwner, PrizeDrawProductApi api, DataResult.Result<HttpBean<ArrayList<LotteryBean>>> result) {
        EasyHttp.get(lifecycleOwner)
                .tag(api.getApi())
                .api(api).request(new OnHttpListener<HttpBean<ArrayList<LotteryBean>>>() {
                    @Override
                    public void onHttpSuccess(HttpBean<ArrayList<LotteryBean>> response) {
                        if (response == null) {
                            ResponseStatus responseStatus = new ResponseStatus("未知错误", false, ResultSource.NETWORK);
                            result.onResult(new DataResult<>(null, responseStatus));
                            return;
                        }
                        ResponseStatus responseStatus = new ResponseStatus(response.getMsg(), response.isRequestSuccess(), ResultSource.NETWORK);
                        result.onResult(new DataResult<>(response, responseStatus));
                    }

                    @Override
                    public void onHttpFail(Exception e) {
                        ResponseStatus responseStatus = new ResponseStatus(e.getMessage(), false, ResultSource.NETWORK);
                        result.onResult(new DataResult<>(null, responseStatus));
                    }
                });

    }

    public void prizeDrawRule(LifecycleOwner lifecycleOwner, PrizeDrawRuleAPi api, DataResult.Result<HttpBean<PrizeDrawRuleBean>> result) {
        EasyHttp.get(lifecycleOwner)
                .tag(api.getApi())
                .api(api).request(new OnHttpListener<HttpBean<PrizeDrawRuleBean>>() {
                    @Override
                    public void onHttpSuccess(HttpBean<PrizeDrawRuleBean> response) {
                        if (response == null) {
                            ResponseStatus responseStatus = new ResponseStatus("未知错误", false, ResultSource.NETWORK);
                            result.onResult(new DataResult<>(null, responseStatus));
                            return;
                        }
                        ResponseStatus responseStatus = new ResponseStatus(response.getMsg(), response.isRequestSuccess(), ResultSource.NETWORK);
                        result.onResult(new DataResult<>(response, responseStatus));
                    }

                    @Override
                    public void onHttpFail(Exception e) {
                        ResponseStatus responseStatus = new ResponseStatus(e.getMessage(), false, ResultSource.NETWORK);
                        result.onResult(new DataResult<>(null, responseStatus));
                    }
                });

    }

    public void prizeDrawRuleList(LifecycleOwner lifecycleOwner, PrizeDrawRuleListAPi api, DataResult.Result<HttpBean<ArrayList<GetPrizeDrawBean>>> result) {
        EasyHttp.get(lifecycleOwner)
                .tag(api.getApi())
                .api(api).request(new OnHttpListener<HttpBean<ArrayList<GetPrizeDrawBean>>>() {
                    @Override
                    public void onHttpSuccess(HttpBean<ArrayList<GetPrizeDrawBean>> response) {
                        if (response == null) {
                            ResponseStatus responseStatus = new ResponseStatus("未知错误", false, ResultSource.NETWORK);
                            result.onResult(new DataResult<>(null, responseStatus));
                            return;
                        }
                        ResponseStatus responseStatus = new ResponseStatus(response.getMsg(), response.isRequestSuccess(), ResultSource.NETWORK);
                        result.onResult(new DataResult<>(response, responseStatus));
                    }

                    @Override
                    public void onHttpFail(Exception e) {
                        ResponseStatus responseStatus = new ResponseStatus(e.getMessage(), false, ResultSource.NETWORK);
                        result.onResult(new DataResult<>(null, responseStatus));
                    }
                });

    }


    public void prizeRes(LifecycleOwner lifecycleOwner, PrizeResAPi api, DataResult.Result<HttpBean<PrizeResBean>> result) {
        EasyHttp.get(lifecycleOwner)
                .tag(api.getApi())
                .api(api).request(new OnHttpListener<HttpBean<PrizeResBean>>() {
                    @Override
                    public void onHttpSuccess(HttpBean<PrizeResBean> response) {
                        if (response == null) {
                            ResponseStatus responseStatus = new ResponseStatus("未知错误", false, ResultSource.NETWORK);
                            result.onResult(new DataResult<>(null, responseStatus));
                            return;
                        }
                        ResponseStatus responseStatus = new ResponseStatus(response.getMsg(), response.isRequestSuccess(), ResultSource.NETWORK);
                        result.onResult(new DataResult<>(response, responseStatus));
                    }

                    @Override
                    public void onHttpFail(Exception e) {
                        ResponseStatus responseStatus = new ResponseStatus(e.getMessage(), false, ResultSource.NETWORK);
                        result.onResult(new DataResult<>(null, responseStatus));
                    }
                });

    }


    public void signCount(LifecycleOwner lifecycleOwner, QuerySignCountAPi api, DataResult.Result<HttpBean<Integer>> result) {
        EasyHttp.get(lifecycleOwner)
                .tag(api.getApi())
                .api(api).request(new OnHttpListener<HttpBean<Integer>>() {
                    @Override
                    public void onHttpSuccess(HttpBean<Integer> response) {
                        if (response == null) {
                            ResponseStatus responseStatus = new ResponseStatus("未知错误", false, ResultSource.NETWORK);
                            result.onResult(new DataResult<>(null, responseStatus));
                            return;
                        }
                        ResponseStatus responseStatus = new ResponseStatus(response.getMsg(), response.isRequestSuccess(), ResultSource.NETWORK);
                        result.onResult(new DataResult<>(response, responseStatus));
                    }

                    @Override
                    public void onHttpFail(Exception e) {
                        ResponseStatus responseStatus = new ResponseStatus(e.getMessage(), false, ResultSource.NETWORK);
                        result.onResult(new DataResult<>(null, responseStatus));
                    }
                });

    }

    public void rankingList(LifecycleOwner lifecycleOwner, RankingListAPi api, DataResult.Result<HttpBean<RankingListBean>> result) {
        EasyHttp.get(lifecycleOwner)
                .tag(api.getApi())
                .api(api).request(new OnHttpListener<HttpBean<RankingListBean>>() {
                    @Override
                    public void onHttpSuccess(HttpBean<RankingListBean> response) {
                        if (response == null) {
                            ResponseStatus responseStatus = new ResponseStatus("未知错误", false, ResultSource.NETWORK);
                            result.onResult(new DataResult<>(null, responseStatus));
                            return;
                        }
                        ResponseStatus responseStatus = new ResponseStatus(response.getMsg(), response.isRequestSuccess(), ResultSource.NETWORK);
                        result.onResult(new DataResult<>(response, responseStatus));
                    }

                    @Override
                    public void onHttpFail(Exception e) {
                        ResponseStatus responseStatus = new ResponseStatus(e.getMessage(), false, ResultSource.NETWORK);
                        result.onResult(new DataResult<>(null, responseStatus));
                    }
                });

    }

    public void myTeam(LifecycleOwner lifecycleOwner, MyTeamAPi api, DataResult.Result<HttpBean<MyTeamBean>> result) {
        EasyHttp.post(lifecycleOwner)
                .tag(api.getApi())
                .api(api).request(new OnHttpListener<HttpBean<MyTeamBean>>() {
                    @Override
                    public void onHttpSuccess(HttpBean<MyTeamBean> response) {
                        if (response == null) {
                            ResponseStatus responseStatus = new ResponseStatus("未知错误", false, ResultSource.NETWORK);
                            result.onResult(new DataResult<>(null, responseStatus));
                            return;
                        }
                        ResponseStatus responseStatus = new ResponseStatus(response.getMsg(), response.isRequestSuccess(), ResultSource.NETWORK);
                        result.onResult(new DataResult<>(response, responseStatus));
                    }

                    @Override
                    public void onHttpFail(Exception e) {
                        ResponseStatus responseStatus = new ResponseStatus(e.getMessage(), false, ResultSource.NETWORK);
                        result.onResult(new DataResult<>(null, responseStatus));
                    }
                });
    }


    public void updateUser(LifecycleOwner lifecycleOwner, UpdateUserApi api, DataResult.Result<HttpBean> result) {
        EasyHttp.post(lifecycleOwner)
                .tag(api.getApi())
                .api(api).request(new OnHttpListener<HttpBean>() {
                    @Override
                    public void onHttpSuccess(HttpBean response) {
                        if (response == null) {
                            ResponseStatus responseStatus = new ResponseStatus("未知错误", false, ResultSource.NETWORK);
                            result.onResult(new DataResult<>(null, responseStatus));
                            return;
                        }
                        ResponseStatus responseStatus = new ResponseStatus(response.getMsg(), response.isRequestSuccess(), ResultSource.NETWORK);
                        result.onResult(new DataResult<>(response, responseStatus));
                    }

                    @Override
                    public void onHttpFail(Exception e) {
                        ResponseStatus responseStatus = new ResponseStatus(e.getMessage(), false, ResultSource.NETWORK);
                        result.onResult(new DataResult<>(null, responseStatus));
                    }
                });

    }


    public void updatePwd(LifecycleOwner lifecycleOwner, UpdatePwdAPi api, DataResult.Result<HttpBean> result) {
        EasyHttp.put(lifecycleOwner)
                .tag(api.getApi())
                .api(api).request(new OnHttpListener<HttpBean>() {
                    @Override
                    public void onHttpSuccess(HttpBean response) {
                        if (response == null) {
                            ResponseStatus responseStatus = new ResponseStatus("未知错误", false, ResultSource.NETWORK);
                            result.onResult(new DataResult<>(null, responseStatus));
                            return;
                        }
                        ResponseStatus responseStatus = new ResponseStatus(response.getMsg(), response.isRequestSuccess(), ResultSource.NETWORK);
                        result.onResult(new DataResult<>(response, responseStatus));
                    }

                    @Override
                    public void onHttpFail(Exception e) {
                        ResponseStatus responseStatus = new ResponseStatus(e.getMessage(), false, ResultSource.NETWORK);
                        result.onResult(new DataResult<>(null, responseStatus));
                    }
                });

    }


    public void unsubscribe(LifecycleOwner lifecycleOwner, UnsubscribeApi api, DataResult.Result<HttpBean> result) {
        EasyHttp.post(lifecycleOwner)
                .tag(api.getApi())
                .api(api).request(new OnHttpListener<HttpBean>() {
                    @Override
                    public void onHttpSuccess(HttpBean response) {
                        if (response == null) {
                            ResponseStatus responseStatus = new ResponseStatus("未知错误", false, ResultSource.NETWORK);
                            result.onResult(new DataResult<>(null, responseStatus));
                            return;
                        }
                        ResponseStatus responseStatus = new ResponseStatus(response.getMsg(), response.isRequestSuccess(), ResultSource.NETWORK);
                        result.onResult(new DataResult<>(response, responseStatus));
                    }

                    @Override
                    public void onHttpFail(Exception e) {
                        ResponseStatus responseStatus = new ResponseStatus(e.getMessage(), false, ResultSource.NETWORK);
                        result.onResult(new DataResult<>(null, responseStatus));
                    }
                });

    }


    public void winning(LifecycleOwner lifecycleOwner, WinningApi api, DataResult.Result<HttpBean<WinnerBean>> result) {
        EasyHttp.get(lifecycleOwner)
                .tag(api.getApi())
                .api(api).request(new OnHttpListener<HttpBean<WinnerBean>>() {
                    @Override
                    public void onHttpSuccess(HttpBean<WinnerBean> response) {
                        if (response == null) {
                            ResponseStatus responseStatus = new ResponseStatus("未知错误", false, ResultSource.NETWORK);
                            result.onResult(new DataResult<>(null, responseStatus));
                            return;
                        }
                        ResponseStatus responseStatus = new ResponseStatus(response.getMsg(), response.isRequestSuccess(), ResultSource.NETWORK);
                        result.onResult(new DataResult<>(response, responseStatus));
                    }

                    @Override
                    public void onHttpFail(Exception e) {
                        ResponseStatus responseStatus = new ResponseStatus(e.getMessage(), false, ResultSource.NETWORK);
                        result.onResult(new DataResult<>(null, responseStatus));
                    }
                });

    }

    public void resetPwd(LifecycleOwner lifecycleOwner, ResetPwdApi api, DataResult.Result<HttpBean> result) {
        EasyHttp.put(lifecycleOwner)
                .tag(api.getApi())
                .api(api).request(new OnHttpListener<HttpBean>() {
                    @Override
                    public void onHttpSuccess(HttpBean response) {
                        if (response == null) {
                            ResponseStatus responseStatus = new ResponseStatus("未知错误", false, ResultSource.NETWORK);
                            result.onResult(new DataResult<>(null, responseStatus));
                            return;
                        }
                        ResponseStatus responseStatus = new ResponseStatus(response.getMsg(), response.isRequestSuccess(), ResultSource.NETWORK);
                        result.onResult(new DataResult<>(response, responseStatus));
                    }

                    @Override
                    public void onHttpFail(Exception e) {
                        ResponseStatus responseStatus = new ResponseStatus(e.getMessage(), false, ResultSource.NETWORK);
                        result.onResult(new DataResult<>(null, responseStatus));
                    }
                });

    }

    public void sendSms(LifecycleOwner lifecycleOwner, SendSmsCodeApi api, DataResult.Result<HttpBean> result) {
        EasyHttp.get(lifecycleOwner)
                .tag(api.getApi())
                .api(api).request(new OnHttpListener<HttpBean>() {
                    @Override
                    public void onHttpSuccess(HttpBean response) {
                        if (response == null) {
                            ResponseStatus responseStatus = new ResponseStatus("未知错误", false, ResultSource.NETWORK);
                            result.onResult(new DataResult<>(null, responseStatus));
                            return;
                        }
                        ResponseStatus responseStatus = new ResponseStatus(response.getMsg(), response.isRequestSuccess(), ResultSource.NETWORK);
                        result.onResult(new DataResult<>(response, responseStatus));
                    }

                    @Override
                    public void onHttpFail(Exception e) {
                        ResponseStatus responseStatus = new ResponseStatus(e.getMessage(), false, ResultSource.NETWORK);
                        result.onResult(new DataResult<>(null, responseStatus));
                    }
                });

    }

    public void register(LifecycleOwner lifecycleOwner, RegisterApi api, DataResult.Result<HttpBean> result) {
        EasyHttp.post(lifecycleOwner)
                .tag(api.getApi())
                .api(api).request(new OnHttpListener<HttpBean>() {
                    @Override
                    public void onHttpSuccess(HttpBean response) {
                        if (response == null) {
                            ResponseStatus responseStatus = new ResponseStatus("未知错误", false, ResultSource.NETWORK);
                            result.onResult(new DataResult<>(null, responseStatus));
                            return;
                        }
                        ResponseStatus responseStatus = new ResponseStatus(response.getMsg(), response.isRequestSuccess(), ResultSource.NETWORK);
                        result.onResult(new DataResult<>(response, responseStatus));
                    }

                    @Override
                    public void onHttpFail(Exception e) {
                        ResponseStatus responseStatus = new ResponseStatus(e.getMessage(), false, ResultSource.NETWORK);
                        result.onResult(new DataResult<>(null, responseStatus));
                    }
                });

    }

    public void getPrizeCount(LifecycleOwner lifecycleOwner, GetPrizeCountApi api, DataResult.Result<HttpBean> result) {
        EasyHttp.get(lifecycleOwner)
                .tag(api.getApi())
                .api(api).request(new OnHttpListener<HttpBean>() {
                    @Override
                    public void onHttpSuccess(HttpBean response) {
                        if (response == null) {
                            ResponseStatus responseStatus = new ResponseStatus("未知错误", false, ResultSource.NETWORK);
                            result.onResult(new DataResult<>(null, responseStatus));
                            return;
                        }
                        ResponseStatus responseStatus = new ResponseStatus(response.getMsg(), response.isRequestSuccess(), ResultSource.NETWORK);
                        result.onResult(new DataResult<>(response, responseStatus));
                    }

                    @Override
                    public void onHttpFail(Exception e) {
                        ResponseStatus responseStatus = new ResponseStatus(e.getMessage(), false, ResultSource.NETWORK);
                        result.onResult(new DataResult<>(null, responseStatus));
                    }
                });

    }

    public void cancelHtpp(String tag) {
        EasyHttp.cancel(tag);
    }
}
